<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>注册有学账号</title>
    <?php include_stylesheets() ?>
    <?php include_javascripts() ?>
  </head>
  <body>  
    <div class="container">
      <div class="header">
        <a class="navbar-brand navbar-logo pull-left" href="#" title=""></a>
      </div>
                      <?php if($sf_user->hasFlash('error')): ?> 
              <?php endif; ?>
      <div class="register">
        <div class="register-form">
          <h1 class="title text-center">注册有学账号</h1>
          <form class="form-horizontal" action="#" method="post" id="reg_form">           
            <div class="verify">
              <!--<div class="form-group">-->
<!--                <select class="form-control">
                  <option>中国(+86)</option>
                </select>-->
              <!--</div>-->
              <div class="form-group <?php if($sf_user->hasFlash('phone-error')): ?> 
                   has-error
              <?php endif; ?>">
                  <input type="text" class="form-control" id="phone" name="phone" placeholder="请填写手机号码" value="<?php echo $sf_request->getParameter('phone',''); ?>">
                <?php if($sf_user->hasFlash('phone-error')): ?> 
                  <p class="form-control-static"><?php echo $sf_user->getFlash('phone-error'); ?></p>
              <?php endif; ?>
              </div>
              <div class="form-group  <?php if($sf_user->hasFlash('code-error')): ?> 
                   has-error
              <?php endif; ?>">
                <div class="row">
                  <div class="col-sm-7 ">
                    <input type="text" class="form-control" id="phone_code" name="phone_code" placeholder="请填写您收到的验证码" value='<?php echo $sf_request->getParameter('phone_code',''); ?>'>
                    <?php if($sf_user->hasFlash('code-error')): ?> 
                 <p class="form-control-static">验证码错误</p>
              <?php endif; ?>
                  </div>
                  <div class="col-sm-5">
                    <button class="btn btn-default" id="send_sms">获取短信验证码</button>
                  </div>
                </div>
              </div>
              <div class="form-group <?php if($sf_user->hasFlash('password-error')): ?> 
                   has-error
              <?php endif; ?>">
                <input type="password" class="form-control" id="" name='password' placeholder="请输入密码">
                <?php if($sf_user->hasFlash('password-error')): ?> 
                 <p class="form-control-static">密码格式错误！</p>
              <?php endif; ?>
              </div>
              <div class="form-group <?php if($sf_user->hasFlash('password-2-error')): ?> 
                   has-error
              <?php endif; ?>">
                <input type="password" class="form-control" id="" name='password_two' placeholder="请再次输入，确认密码">
                <?php if($sf_user->hasFlash('password-2-error')): ?> 
                 <p class="form-control-static"><?php echo $sf_user->getFlash('password-2-error'); ?></p>
              <?php endif; ?>
              </div>
              <div class="form-group">
                <button type="submit" class="btn btn-green btn-lg btn-block" >立即注册</button>
              </div>
              <div class="form-group">
                <p class="eula">点击”立即注册”，即表示您同意并愿意遵守<a href="#">有学用户协议</a>和<a href="#">隐私政策</a></p>
              </div>              
            </div>
          </form>
        </div>
      </div>
    </div>
    <div class="footer text-center">
      <div class="footer-nav"><span class="active">简体</span> &nbsp; <a href="#">繁体</a> &nbsp; <a href="#">English</a> &nbsp; <a href="#">常见问题</a></div>
      <div class="copyright">
        <div>&copy;2014 <a href="#">有学在线教育</a> 上海有学教育科技有限公司版权所有</div>
        <div><a href="#">京ICP证140465号</a> &nbsp; <a href="#">京ICP备13032407号-1</a> &nbsp; <a href="#">京公网安备 11010802013162</a></div>
      </div>
    </div>
      <script type="text/javascript">
          $(document).ready(function(){
              $("#send_sms").click(function(){
                  var phone = $("#phone").val();
                  var  re = /^1\d{10}$/;
                  
                  if(phone.length == 0){
                      alert("请填写手机号！");
                       return false;
                  }else{
                      if (!re.test(phone)) {
                        alert("请填写正确的手机号！");
                         return false;
                      }else{
                        $.post("<?php echo url_for('user/send_sms'); ?>",{'phone':phone},function(msg){
                            alert(msg);
                        });
                      }
                      
                  }
                  return false;
              });
          });
      </script>
  </body>
</html>